home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.lib;
-
- import java.awt.Font;
-
- /**
- * Subclass of label that displays the integer value associated with its
- * value_a part. Note: set_text() which is inherited from label allows
- * the displayed string to be set to something other than the value of
- * part_a (even if there is a constraint). Use of this is "a feature",
- * however, is problematical for most uses since any such string will be
- * wiped out when part_a is next assigned or computed by the constraint
- * system (which is essentially an unpredictable occurrence).
- *
- * @author Scott Hudson
- */
- public class int_label extends label {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Full constructor.
- * @param int val the value to display.
- * @param int w the width of the resulting object.
- * @param Font f the font to draw in.
- */
- public int_label(int val, int width, Font f)
- {
- super(Integer.toString(val), width, f);
- _part_a = val;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor with width defaulting to width of initial displayed value.
- * @param int val the value to display.
- * @param Font f the font to draw in.
- */
- public int_label(int val, Font f)
- {
- super(Integer.toString(val), f);
- _part_a = val;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor with default font.
- * @param int val the value to display.
- * @param int w the width of the resulting object.
- */
- public int_label(int val, int width)
- {
- super(Integer.toString(val), width);
- _part_a = val;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor with width set by initial display and default font.
- * @param int val the value to display.
- */
- public int_label(int val)
- {
- super(Integer.toString(val));
- _part_a = val;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Constructor defaulting to 0 value with default width and font. */
- public int_label()
- {
- this(0);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Indicate which values (coordinates/sizes) of this object are
- * intrinsically constrained by the internals of the object. In this
- * case we need to remove PART_A from the set reported by our
- * superclass.
- *
- * @return int bitset indicating parts of this object that are intrinsically
- * defined.
- */
- public int intrinsic_constraints()
- {
- return super.intrinsic_constraints() & ~PART_A;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Storage for part_a value (which we display). */
- protected int _part_a = 0;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the value of part_a after evaluating any attached constraints.
- * @return int up-to-date value of part_a.
- */
- public int part_a()
- {
- /* evaluate and return the value */
- eval_part_a();
- return _part_a;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Set part_a value directly bypassing the constraint system.
- * @param int v the new value.
- */
- protected void set_raw_part_a(int v)
- {
- /* don't do anything unless this is a change */
- if (v != _part_a)
- {
- /* change the value and damage our image */
- _part_a = v;
- super.set_text(Integer.toString(v));
- damage_self();
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Set part_a of object.
- * @param int v the new value.
- */
- public void set_part_a(int v)
- {
- /* if this has a constraint throw an exception */
- if ((active_constraints() & PART_A) != 0)
- throw new sub_arctic_error(
- "Attempt to assign value to constrained part_a");
-
- /* don't do anything unless this is a change */
- if (v != _part_a)
- {
- set_raw_part_a(v);
- mark_part_a_ood();
- }
- }
-
- //had:
- //* @exception cannot_assign if part_a is controlled by a constraint.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-